package com.bcu.model.controller;

import com.bcu.model.service.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class PayController {

    @GetMapping("/pay")
    public String doPayController(String body,String total_fee,String openid,String payPath)throws Exception{

        PayContext payContext;

        Map param=new HashMap<>();
        param.put("body",body);
        param.put("total_fee",total_fee);
        param.put("openid",openid);


        PayStrategyFactory factory=(PayStrategyFactory)Class.forName(payPath).newInstance();
        PayStrategy p=factory.createPayStragegy();


        String result=new PayContext(p).doPay(param);

        return result;


    }
}
